const http = require("../../http/http")
const API = require("../../http/API")

// pages/course/course.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		classList: ["最新", "入门", "进阶", "免费", "图文", "兑换", "专题"],
		banners: [],
		courseGroupList: [],
		isTrue: true,
		isShowAll: false,
		// 点击的索引值
		activeIndex: 0,
		// 教程 数组
		group_detail: [],
		limit:10
	},
	changeIsShowAll() {
		this.setData({ isShowAll: !this.data.isShowAll })
	},
	change_xz(e) {
		this.setData({ activeIndex: e.currentTarget.dataset.index })
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		this.setData({page: 1})
		// 轮播图
		http(API.banners).then(res => {
			this.setData({ banners: res.data.data })
		})
		// 分类
		http(API.courseGroupList).then(res => {
			this.setData({ courseGroupList: res.data.course_subjects })
			console.log(res.data.course_subjects);
		})
		// 详情
		http(API.courseVideo + `?type=1&page=${this.data.page}&limit=10`).then(res => {
			console.log(res.data.data);
			this.setData({ group_detail: res.data.data })
		})
	},
	onReachBottom() {
		this.setData({
		limit: this.data.limit +10})
		http(API.courseVideo + `?type=1&page=1&limit=${this.data.limit}`).then(res => {
			this.setData({ group_detail: res.data.data })
			console.log(this.data.group_detail);
		})
	}

})